home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / fsconsist.h < prev    next >
C/C++ Source or Header  |  1990-12-08  |  8KB  |  222 lines

  1. /*
  2.  * fsconsist.h --
  3.  *
  4.  *    Declarations for cache consistency routines.
  5.  *
  6.  * Copyright 1987 Regents of the University of California
  7.  * All rights reserved.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * $Header: /sprite/src/kernel/fsconsist/RCS/fsconsist.h,v 9.7 90/12/06 21:57:02 jhh Exp $ SPRITE (Berkeley)
  17.  */
  18.  
  19. #ifndef _FSCONSIST
  20. #define _FSCONSIST
  21.  
  22. #ifdef KERNEL
  23. #include <fs.h>
  24. #include <fsio.h>
  25. #include <rpc.h>
  26. #else
  27. #include <kernel/fs.h>
  28. #include <kernel/fsio.h>
  29. #include <kernel/rpc.h>
  30. #endif
  31. /*
  32.  * Flags to determine what type of consistency operation is required.
  33.  *
  34.  *        FSCONSIST_WRITE_BACK_BLOCKS    Write back all dirty blocks.
  35.  *        FSCONSIST_INVALIDATE_BLOCKS    Invalidate all block in the cache for this
  36.  *                file.  This means that the file is no longer
  37.  *                cacheable.
  38.  *        FSCONSIST_DELETE_FILE        Delete the file from the local cache and
  39.  *                the file handle table.
  40.  *        FSCONSIST_CANT_CACHE_NAMED_PIPE    The named pipe is no longer read cacheable
  41.  *                on the client.  This would happen if two
  42.  *                separate clients tried to read the named pipe
  43.  *                at the same time.
  44.  *    FSCONSIST_WRITE_BACK_ATTRS    Write back the cached attributes.
  45.  *    FSCONSIST_DEBUG    Forces machine into debugger
  46.  *    FSCONSIST_MIGRATION    Consistency operation is due to migration
  47.  *                (for statistics purposes).
  48.  */
  49.  
  50. #define    FSCONSIST_WRITE_BACK_BLOCKS        0x01
  51. #define    FSCONSIST_INVALIDATE_BLOCKS        0x02
  52. #define    FSCONSIST_DELETE_FILE            0x04
  53. #define    FSCONSIST_CANT_CACHE_NAMED_PIPE        0x08
  54. #define    FSCONSIST_WRITE_BACK_ATTRS        0x10
  55. #define FSCONSIST_DEBUG                0x100
  56. #define    FSCONSIST_MIGRATION            0x200
  57.  
  58. /*
  59.  * The client use state needed to allow remote client access and to
  60.  * enforce network cache consistency.  A list of state for each client
  61.  * using the file is kept, including the name server itself.  This
  62.  * is used to determine what cache consistency actions to take.
  63.  * There is synchronization over this list between subsequent open
  64.  * operations and the cache consistency actions themselves.
  65.  */
  66.  
  67. typedef struct Fsconsist_Info {
  68.     Sync_Lock    lock;        /* Monitor lock used to synchronize access
  69.                  * to cache consistency routines and the
  70.                  * consistency list. */
  71.     int        flags;        /* Flags defined in fsCacheConsist.c */
  72.     int        lastWriter;    /* Client id of last client to have it open
  73.                    for write caching. */
  74.     int        openTimeStamp;    /* Generated on the server when the file is
  75.                  * opened.  Checked on clients to catch races
  76.                  * between open replies and consistency
  77.                  * messages */
  78.     Fs_HandleHeader *hdrPtr;    /* Back pointer to handle header needed to
  79.                  * identify the file. */
  80.     List_Links    clientList;    /* List of clients of this file.  Scanned
  81.                  * to determine cachability conflicts */
  82.     List_Links    msgList;    /* List of outstanding cache
  83.                  * consistency messages. */
  84.     Sync_Condition consistDone;    /* Opens block on this condition
  85.                  * until ongoing cache consistency
  86.                  * actions have completed */
  87.     Sync_Condition repliesIn;    /* This condition is notified after
  88.                  * all the clients told to take
  89.                  * consistency actions have replied. */
  90. } Fsconsist_Info;
  91.  
  92. /*
  93.  * Structure to contain information for each client that is using a file.
  94.  */
  95.  
  96. typedef struct Fsconsist_ClientInfo {
  97.     List_Links    links;        /* This hangs in a list off the I/O handle */
  98.     int        clientID;    /* The sprite ID of this client. */
  99.     Fsio_UseCounts use;        /* Usage info for the client.  Used to clean
  100.                  * up summary counts when client crashes. */
  101.     /*
  102.      * The following fields are only used by regular files.
  103.      */
  104.     Boolean    cached;        /* TRUE if the file is cached on this client. */
  105.     int        openTimeStamp;    /* The most recent open of this file. */
  106.     Boolean    locked;        /* TRUE when a pointer is held to this client
  107.                  * list element.  It is not appropriate to
  108.                  * garbage collect the element when set. */
  109.     Boolean    mapped;        /* TRUE if the client is mapping the
  110.                  * file into memory. */
  111. } Fsconsist_ClientInfo;
  112.  
  113. /*
  114.  * INSERT_CLIENT takes care of initializing a new client list entry.
  115.  */
  116. #define INSERT_CLIENT(clientList, clientPtr, clientID) \
  117.     fs_Stats.object.fileClients++;        \
  118.     clientPtr = mnew(Fsconsist_ClientInfo);    \
  119.     clientPtr->clientID = clientID;        \
  120.     clientPtr->use.ref = 0;            \
  121.     clientPtr->use.write = 0;            \
  122.     clientPtr->use.exec = 0;            \
  123.     clientPtr->openTimeStamp = 0;        \
  124.     clientPtr->cached = FALSE;            \
  125.     clientPtr->locked = FALSE;            \
  126.     clientPtr->mapped = FALSE;            \
  127.     List_InitElement((List_Links *)clientPtr);    \
  128.     List_Insert((List_Links *) clientPtr, LIST_ATFRONT(clientList));
  129.  
  130. /*
  131.  * REMOVE_CLIENT takes care of removing a client list entry.
  132.  */
  133. #define REMOVE_CLIENT(clientPtr) \
  134.     fs_Stats.object.fileClients--;        \
  135.     List_Remove((List_Links *) clientPtr);    \
  136.     free((Address) clientPtr);
  137.  
  138. #ifdef KERNEL
  139. /*
  140.  * This header file (fsioFile.h) is needed to define Fsio_FileIOHandle for the
  141.  * function prototypes below. It must occur after Fsconsist_Info is defined.
  142.  */
  143. #include <fsioFile.h>
  144. /*
  145.  * Client list routines.
  146.  */
  147. extern void Fsconsist_ClientInit _ARGS_((void));
  148. extern Fsconsist_ClientInfo *Fsconsist_IOClientOpen _ARGS_((
  149.             List_Links *clientList, int clientID, int useFlags,
  150.             Boolean cached));
  151. extern Boolean Fsconsist_IOClientReopen _ARGS_((List_Links *clientList, 
  152.             int clientID, Fsio_UseCounts *usePtr));
  153. extern Boolean Fsconsist_IOClientClose _ARGS_((List_Links *clientList, 
  154.             int clientID, int flags, Boolean *cachePtr));
  155. extern Boolean Fsconsist_IOClientRemoveWriter _ARGS_((List_Links *clientList,
  156.             int clientID));
  157. extern void Fsconsist_IOClientKill _ARGS_((List_Links *clientList, int clientID,
  158.             int *refPtr, int *writePtr, int *execPtr));
  159. extern void Fsconsist_IOClientStatus _ARGS_((List_Links *clientList, 
  160.             int clientID, Fsio_UseCounts *clientUsePtr));
  161.  
  162.  
  163.  
  164. /*
  165.  * Cache consistency routines.
  166.  */
  167. extern void Fsconsist_Init _ARGS_(( Fsconsist_Info *consistPtr,
  168.             Fs_HandleHeader *hdrPtr));
  169. extern void Fsconsist_SyncLockCleanup _ARGS_((Fsconsist_Info *consistPtr));
  170. extern ReturnStatus Fsconsist_MappedConsistency _ARGS_((
  171.             Fsio_FileIOHandle *handlePtr, int clientID, 
  172.             int isMapped));
  173. extern ReturnStatus Fsconsist_FileConsistency _ARGS_((
  174.             Fsio_FileIOHandle *handlePtr, int clientID, 
  175.             int useFlags, Boolean *cacheablePtr, 
  176.             int *openTimeStampPtr));
  177.  
  178. extern void Fsconsist_ReopenClient _ARGS_((Fsio_FileIOHandle *handlePtr, 
  179.             int clientID, Fsio_UseCounts use, 
  180.             Boolean haveDirtyBlocks));
  181. extern ReturnStatus Fsconsist_ReopenConsistency _ARGS_((
  182.             Fsio_FileIOHandle *handlePtr, int clientID, 
  183.             Fsio_UseCounts use, int swap, Boolean *cacheablePtr, 
  184.             int *openTimeStampPtr));
  185. extern ReturnStatus Fsconsist_MigrateConsistency _ARGS_((
  186.             Fsio_FileIOHandle *handlePtr, int srcClientID, 
  187.             int dstClientID, int useFlags, Boolean closeSrc, 
  188.             Boolean *cacheablePtr, int *openTimeStampPtr));
  189. extern void Fsconsist_GetClientAttrs _ARGS_((Fsio_FileIOHandle *handlePtr, 
  190.             int clientID, Boolean *isExecedPtr));
  191. extern Boolean Fsconsist_Close _ARGS_((register Fsconsist_Info *consistPtr, 
  192.             int clientID, int flags, Boolean *wasCachedPtr));
  193.  
  194. extern void Fsconsist_DeleteLastWriter _ARGS_((Fsconsist_Info *consistPtr, 
  195.             int clientID));
  196. extern void Fsconsist_ClientRemoveCallback _ARGS_((Fsconsist_Info *consistPtr,
  197.             int clientID));
  198. extern void Fsconsist_Kill _ARGS_((Fsconsist_Info *consistPtr, int clientID, 
  199.             int *refPtr, int *writePtr, int *execPtr));
  200. extern void Fsconsist_GetAllDirtyBlocks _ARGS_((int domain, Boolean invalidate));
  201. extern void Fsconsist_FetchDirtyBlocks _ARGS_((Fsconsist_Info *consistPtr, 
  202.             Boolean invalidate));
  203.  
  204. extern ReturnStatus Fsconsist_RpcConsist _ARGS_((ClientData srvToken, 
  205.             int clientID, int command, Rpc_Storage *storagePtr));
  206. extern ReturnStatus Fsconsist_RpcConsistReply _ARGS_((ClientData srvToken, 
  207.             int clientID, int command, Rpc_Storage *storagePtr));
  208.  
  209.  
  210. #ifdef SOSP91
  211. extern int Fsconsist_NumClients _ARGS_((Fsconsist_Info *consistPtr,
  212.                     int *numReadPtr, int *numWritePtr));
  213. #else
  214. extern int Fsconsist_NumClients _ARGS_((Fsconsist_Info *consistPtr));
  215. #endif
  216.  
  217. extern void Fsconsist_AddClient _ARGS_((int clientID));
  218.  
  219. #endif
  220.  
  221. #endif _FSCONSIST
  222.